<?php

namespace builder\test\controllers;

use builder\base\BaseController;
use builder\helper\H5;

/**
 * 列表
 */
class ListsController extends BaseController
{
    public $actionVerbs = ['index' => ['GET', 'POST']];
    public $publicActions = ['index'];

    //示例
    public function actionIndex()
    {
        $viewBuilder = $this->viewBuilder;
        $viewBuilder->setPartial();

        $lists = $viewBuilder->lists;
        $lists->setTitle('详情构建器')
            ->setListRows([
                [
                    '班级' => $this->listRows->item('二班')->thAttribute(['width' => 90]),
                    '班主任' => $this->listRows->item('李阳')->thAttribute(['width' => 90]),
                    '联系方式' => $this->listRows->item('12225478878')->thAttribute(['width' => 90]),
                ],
                [
                    '用户名' => $this->listRows->item('Clevstn'),
                    '积分' => $this->listRows->item(500),
                    '状态' => $this->listRows->item(function () {
                        return H5::badge('成功');
                    }),
                ],
                '手机号' => $this->listRows->item(function () {
                    return '15030321254';
                })->tdAttribute(['colspan' => 5]),
                '订单号' => $this->listRows->item('N01878016587493544427')->tdAttribute(['colspan' => 5]),
                '平台' => $this->listRows->item('淘宝')->tdAttribute(['colspan' => 5]),
                '店铺' => $this->listRows->item('Wd028,爱吃鱼')->tdAttribute(['colspan' => 5]),
                '省' => $this->listRows->item('河南省')->tdAttribute(['colspan' => 5]),
                '市' => $this->listRows->item('郑州市')->tdAttribute(['colspan' => 5]),
                '区(县)' => $this->listRows->item('金水区')->tdAttribute(['colspan' => 5]),
                '详细地址' => $this->listRows->item('国贸大厦102')->tdAttribute(['colspan' => 5]),
                '商品信息' => $this->listRows->item('闪迪512g/1700 CFE卡')->tdAttribute(['colspan' => 5]),
                '员工' => $this->listRows->item('李四')->tdAttribute(['colspan' => 5]),
                '订单金额' => $this->listRows->item('100.00')->tdAttribute(['colspan' => 5]),
                '收益' => $this->listRows->item('20.00')->tdAttribute(['colspan' => 5]),
                '提成' => $this->listRows->item('5.00')->tdAttribute(['colspan' => 5]),
                '注册时间' => $this->listRows->item('2023/03/02 02:00')->tdAttribute(['colspan' => 5]),
            ]);

        return $viewBuilder->render();
    }
}